<template>
  <div class="topbar">
    <div class="top-area">
      <div class="topbar-right">
        <el-dropdown @command="handleCommand">
          <el-button type="primary">
            {{ $store.state.user.username }}
            <i class="el-icon-arrow-down el-icon--right"></i>
          </el-button>
          <el-dropdown-menu slot="dropdown">
            <el-dropdown-item command="logout">ExitSystem</el-dropdown-item>
          </el-dropdown-menu>
        </el-dropdown>
      </div>
    </div>
  </div>
</template>


<script>
import { mapActions } from "vuex";

export default {
  name: "topbar",

  components: {},

  data() {
    return {
      lang: window.localStorage.getItem("language") || "en"
    };
  },

  computed: {
    activeLink() {
      return this.$route.path === "/help";
    }
  },

  methods: {
    ...mapActions(["USER_LOGIN"]),
    logout() {
      this.USER_LOGIN({ isLogOut: true });
      this.$router.push({ path: "/login" });
    },
    handleCommand(command) {
     this.logout();
    }
  }
};
</script>


<style lang="scss">
.topbar {
  height: 60px;
  line-height: 60px;
  padding-left: 110px;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 4;
  .top-area {
    background-color: #242327;
    height: 100%;
    padding: 0 32px;
    text-align: right;
    .topbar-right {
      .help-link {
        display: inline;
        line-height: 32px;
        .link {
          display: inline-block;
          color: #82858f;
          padding: 0 20px;
          border-right: 1px solid #2b2c30;
          position: relative;
          top: 3px;
          .icon-bangzhu {
            font-size: 20px;
          }
        }
        a.active {
          color: #34c388;
        }
      }
      .el-button {
        width: 135px;
        border-radius: 40px;
        border-width: 2px;
        margin-left: 20px;
        font-size: 14px;
        font-weight: 400;
        line-height: 15px;
        background: transparent;
        &.enterprise-btn {
          color: #34c388;
          border-color: #34c388;
          .icon-arrow {
            position: relative;
            top: 1px;
          }
        }
        &.github-btn {
          color: #adafb4;
          border-color: #adafb4;
        }
        .iconfont {
          margin-left: 5px;
        }
      }
      .el-button--medium {
        padding: 9px 20px;
      }
    }
  }
}
</style>
